# Contributor: Bradley J Chambers <brad.chambers@gmail.com>
# Maintainer: Daniel Tobon <danieltobonco@gmail.com>
pkgname=pcl
pkgver=1.14.0
pkgrel=1
_gtestver=1.12.1
pkgdesc="Point Cloud Library (PCL)"
url="https://pointclouds.org"
arch="all !x86 !s390x" # tests fails on x86 and s390x
license="BSD-3-Clause"
depends_dev="
	boost-dev
	eigen-dev
	flann-dev
	freeglut-dev
	hdf5-dev
	libpcap-dev
	libusb-dev
	mesa-dev
	qhull-dev
	qhull-static
	qt5-qtbase-dev
	vtk-dev
	"
makedepends="
	$depends_dev
	cmake
	samurai
	"
subpackages="$pkgname-dev $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/PointCloudLibrary/pcl/releases/download/pcl-$pkgver/source.tar.gz
	gtest-release-$_gtestver.tar.gz::https://github.com/google/googletest/archive/release-$_gtestver.tar.gz
	fix-broken-flags.patch
	"
builddir="$srcdir/pcl"

build() {
	case "$CARCH" in
	ppc64le|aarch64)
		local disable_segtests="-DBUILD_tests_segmentation=OFF"
		;;
	esac
	# Five tests are disabled below. This is in keeping with PCL's own
	# Appveyor configuration
	# (https://github.com/PointCloudLibrary/pcl/blob/master/.appveyor.yml),
	# and is due to a list of test failures that are documented in issues
	# #1702, #1719, #1921, and #2136.
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DWITH_CUDA=OFF \
		-DWITH_DAVIDSDK=OFF \
		-DWITH_DSSDK=OFF \
		-DWITH_ENSENSO=OFF \
		-DWITH_FZAPI=OFF \
		-DWITH_LIBUSB=ON \
		-DWITH_OPENGL=ON \
		-DWITH_OPENNI2=OFF \
		-DWITH_OPENNI=OFF \
		-DWITH_PCAP=ON \
		-DWITH_PNG=ON \
		-DWITH_QHULL=ON \
		-DWITH_QT=ON \
		-DWITH_VTK=ON \
		-DBUILD_apps=OFF \
		-DBUILD_examples=OFF \
		-DBUILD_global_tests="$(want_check && echo ON || echo OFF)" \
		-DBUILD_simulation=ON \
		-DBUILD_tests_common=OFF \
		-DBUILD_tests_features=OFF \
		-DBUILD_tests_filters=OFF \
		-DBUILD_tests_io=OFF \
		-DBUILD_tests_registration=OFF \
		-DBUILD_tools=ON \
		-DGTEST_SRC_DIR="$srcdir"/googletest-release-$_gtestver/googletest \
		-DGTEST_INCLUDE_DIR="$srcdir"/googletest-release-$_gtestver/googletest/include \
		-DVTK_RENDERING_BACKEND=OpenGL2 \
		-DPCL_ENABLE_MARCHNATIVE=OFF \
		-DPCL_ENABLE_AVX=OFF \
		-DPCL_ENABLE_SSE=ON \
		$disable_segtests
	cmake --build build
}

dev() {
	default_dev

	amove usr/share
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

check() {
	cd build
	ctest --output-on-failure
}

sha512sums="
bbcd15cf1ae620d46163c7639238bff34a871916d36d275fededbccca2bacd8da6ffda477607c4ef0eb795c140c5e1677b8239cbe2f7576f5ff92035c9c36b3f  pcl-1.14.0.tar.gz
a9104dc6c53747e36e7dd7bb93dfce51a558bd31b487a9ef08def095518e1296da140e0db263e0644d9055dbd903c0cb69380cb2322941dbfb04780ef247df9c  gtest-release-1.12.1.tar.gz
f866bf3c5eb8cf02b3531dff527f103b2f9c2bb454df6455b66e6d2f425e37d938f86efe7ba534d09a5f10a2830178e01853dc73769775d1faa9d049a5c5cc4b  fix-broken-flags.patch
"
